<!DOCTYPE html>
<html lang="zh-CN">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>RocketMQ vs Kafka：深度对比分析</title>
    <link href="https://cdn.staticfile.org/font-awesome/6.4.0/css/all.min.css" rel="stylesheet">
    <link href="https://cdn.staticfile.org/tailwindcss/2.2.19/tailwind.min.css" rel="stylesheet">
    <link href="https://fonts.googleapis.com/css2?family=Noto+Serif+SC:wght@400;500;600;700&family=Noto+Sans+SC:wght@300;400;500;700&display=swap" rel="stylesheet">
    <script src="https://cdn.jsdelivr.net/npm/mermaid@latest/dist/mermaid.min.js"></script>
    <style>
        body {
            font-family: 'Noto Sans SC', Tahoma, Arial, Roboto, "Droid Sans", "Helvetica Neue", "Droid Sans Fallback", "Heiti SC", "Hiragino Sans GB", Simsun, sans-serif;
            background: linear-gradient(135deg, #f5f7fa 0%, #c3cfe2 100%);
            min-height: 100vh;
        }
        
        .hero-gradient {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
        }
        
        .card-hover {
            transition: all 0.3s ease;
            border: 1px solid rgba(255, 255, 255, 0.1);
            backdrop-filter: blur(10px);
        }
        
        .card-hover:hover {
            transform: translateY(-5px);
            box-shadow: 0 20px 40px rgba(0, 0, 0, 0.1);
            border-color: rgba(102, 126, 234, 0.5);
        }
        
        .feature-icon {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            -webkit-background-clip: text;
            -webkit-text-fill-color: transparent;
        }
        
        .section-title {
            position: relative;
            padding-bottom: 1rem;
        }
        
        .section-title::after {
            content: '';
            position: absolute;
            bottom: 0;
            left: 0;
            width: 60px;
            height: 4px;
            background: linear-gradient(90deg, #667eea 0%, #764ba2 100%);
            border-radius: 2px;
        }
        
        .comparison-table {
            background: rgba(255, 255, 255, 0.95);
            border-radius: 16px;
            overflow: hidden;
            box-shadow: 0 10px 30px rgba(0, 0, 0, 0.1);
        }
        
        .mermaid {
            background: rgba(255, 255, 255, 0.9);
            border-radius: 12px;
            padding: 2rem;
            margin: 2rem 0;
        }
        
        .highlight-box {
            background: linear-gradient(135deg, rgba(102, 126, 234, 0.1) 0%, rgba(118, 75, 162, 0.1) 100%);
            border-left: 4px solid #667eea;
            padding: 1.5rem;
            border-radius: 8px;
            margin: 1.5rem 0;
        }
        
        .drop-cap {
            float: left;
            font-size: 4rem;
            line-height: 1;
            font-weight: 700;
            margin-right: 0.5rem;
            margin-top: -0.5rem;
            color: #667eea;
            font-family: 'Noto Serif SC', serif;
        }
        
        @keyframes fadeInUp {
            from {
                opacity: 0;
                transform: translateY(30px);
            }
            to {
                opacity: 1;
                transform: translateY(0);
            }
        }
        
        .animate-fadeInUp {
            animation: fadeInUp 0.8s ease-out;
        }
    </style>
</head>
<body>
    <!-- Hero Section -->
    <section class="hero-gradient text-white py-20">
        <div class="container mx-auto px-6">
            <div class="text-center animate-fadeInUp">
                <h1 class="text-5xl md:text-6xl font-bold mb-6">
                    RocketMQ vs Kafka
                </h1>
                <p class="text-xl md:text-2xl mb-8 opacity-90">
                    深度解析两大主流分布式消息队列系统的架构差异与应用场景
                </p>
                <div class="flex justify-center space-x-8 text-lg">
                    <div class="flex items-center">
                        <i class="fas fa-rocket mr-2"></i>
                        <span>高性能消息传递</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-server mr-2"></i>
                        <span>分布式架构</span>
                    </div>
                    <div class="flex items-center">
                        <i class="fas fa-chart-line mr-2"></i>
                        <span>可扩展性</span>
                    </div>
                </div>
            </div>
        </div>
    </section>

    <!-- Main Content -->
    <main class="container mx-auto px-6 py-12">
        <!-- Introduction -->
        <section class="mb-16 animate-fadeInUp">
            <div class="bg-white rounded-2xl shadow-xl p-8">
                <p class="text-lg leading-relaxed text-gray-700">
                    <span class="drop-cap">R</span>ocketMQ和Kafka作为两款主流的分布式消息队列系统，在架构设计上存在显著差异，这些差异直接影响了它们的性能特性和适用场景。本文将从架构、功能特性、性能和适用场景等多个维度，深入剖析这两个系统的异同，帮助您做出最适合的技术选型。
                </p>
            </div>
        </section>

        <!-- Architecture Comparison -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 section-title">架构差异</h2>
            
            <!-- Architecture Diagram -->
            <div class="mermaid">
                graph TB
                    subgraph RocketMQ架构
                        NS[NameServer<br/>服务发现]
                        BM[Broker Master<br/>主节点]
                        BS[Broker Slave<br/>从节点]
                        P1[Producer<br/>生产者]
                        C1[Consumer<br/>消费者]
                        
                        P1 --> NS
                        C1 --> NS
                        NS --> BM
                        NS --> BS
                        BM --> BS
                        P1 --> BM
                        C1 --> BM
                    end
                    
                    subgraph Kafka架构
                        ZK[ZooKeeper<br/>协调服务]
                        KB[Kafka Broker<br/>消息服务器]
                        P2[Producer<br/>生产者]
                        C2[Consumer<br/>消费者]
                        CT[Controller<br/>控制器]
                        
                        P2 --> KB
                        C2 --> KB
                        KB --> ZK
                        CT --> ZK
                        CT --> KB
                    end
            </div>

            <div class="grid md:grid-cols-2 gap-8 mt-12">
                <!-- RocketMQ Architecture -->
                <div class="card-hover bg-white rounded-xl p-6">
                    <h3 class="text-2xl font-bold mb-4 flex items-center">
                        <i class="fas fa-rocket feature-icon mr-3 text-3xl"></i>
                        RocketMQ 核心架构
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <div>
                                <strong>NameServer：</strong>轻量级的服务发现和路由注册中心，各节点独立运行
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <div>
                                <strong>Broker：</strong>主从架构设计，支持同步/异步复制
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <div>
                                <strong>存储模型：</strong>CommitLog + ConsumeQueue + IndexFile
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-purple-600 mt-1 mr-3"></i>
                            <div>
                                <strong>消费模式：</strong>支持Push和Pull两种方式
                            </div>
                        </li>
                    </ul>
                </div>

                <!-- Kafka Architecture -->
                <div class="card-hover bg-white rounded-xl p-6">
                    <h3 class="text-2xl font-bold mb-4 flex items-center">
                        <i class="fas fa-stream feature-icon mr-3 text-3xl"></i>
                        Kafka 核心架构
                    </h3>
                    <ul class="space-y-3">
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <div>
                                <strong>ZooKeeper：</strong>集群元数据管理和协调（新版本逐步移除）
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <div>
                                <strong>Broker：</strong>分区Leader-Follower架构
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <div>
                                <strong>存储模型：</strong>基于分区的日志段存储
                            </div>
                        </li>
                        <li class="flex items-start">
                            <i class="fas fa-check-circle text-indigo-600 mt-1 mr-3"></i>
                            <div>
                                <strong>消费模式：</strong>仅支持Pull方式
                            </div>
                        </li>
                    </ul>
                </div>
            </div>
        </section>

        <!-- Feature Comparison -->
        <section class="mb-16">
            <h2 class="text-4xl font-bold mb-8 section-title">功能特性对比</h2>
            
            <div class="comparison-table">
                <table class="w-full">
                    <thead>
                        <tr class="bg-gradient-to-r from-purple-600 to-indigo-600 text-white">
                            <th class="py-4 px-6 text-left">功能特性</th>
                            <th class="py-4 px-6 text-center">RocketMQ</th>
                            <th class="py-4 px-6 text-center">Kafka</th>
                        </tr>
                    </thead>
                    <tbody>
                        <tr class="border-b hover:bg-gray-50 transition-colors">
                            <td class="py-4 px-6 font-medium">事务消息</td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-green-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">完善支持</span>
                            </td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-yellow-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">0.11版本后支持</span>
                            </td>
                        </tr>
                        <tr class="border-b hover:bg-gray-50 transition-colors">
                            <td class="py-4 px-6 font-medium">延时消息</td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-green-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">原生支持</span>
                            </td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-times-circle text-red-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">需额外实现</span>
                            </td>
                        </tr>
                        <tr class="border-b hover:bg-gray-50 transition-colors">
                            <td class="py-4 px-6 font-medium">顺序消息</td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-green-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">全局/分区顺序</span>
                            </td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-yellow-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">分区内顺序</span>
                            </td>
                        </tr>
                        <tr class="border-b hover:bg-gray-50 transition-colors">
                            <td class="py-4 px-6 font-medium">消息过滤</td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-green-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">Tag/SQL92</span>
                            </td>
                            <td class="py-4 px-6 text-center">
                                <i class="fas fa-check-circle text-yellow-500 text-xl"></i>
                                <span class="block text-sm text-gray-600 mt-1">客户端过滤</span>